<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<!--<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">-->
<title><c:out value="${not empty bean.id ? '修改用户我的应用信息':'新增用户我的应用信息'}" /></title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<jsp:include page="../common/import.jsp"></jsp:include>

</head>
<body>
    <!-- <div class="iframe-cot pt0" id="smIframe"> -->
    <div class="right-form mt0">
       <form class="add-form" id="editForm" method="post" action="#" onsubmit="return false;">
          <input id="s_id" type="hidden" value="${bean.id}">
		<ul class="w100 layer-form">
               <li>
                   <label class="ser-label">应用名称：</label>
                   <div class="form-content">
                   <input id="s_appName" name="name" class="inputText" value="${bean.appName}" type="text" disabled>
                   </div>
               </li>
                <li>
                   <label class="ser-label"><em style="color:red;">*</em>排序号：</label>
                   <div class="form-content">
					  <input id="s_showOrder" name="showOrder" class="inputText" value="${bean.showOrder}" type="text" maxlength="5">
                   	  <div class="form-tips text-red" ></div>
                   </div>
               </li>
               
               <li class="w-per">
                   <label class="ser-label">&nbsp;</label>
                   <div class="form-content clearfix">
                       <button class="btn btn-orange" id="savebtn" onclick="save()" ><i class="fa fa-save mr5"></i>保存</button>
                       <button id="cancelBtn" class="btn btn-default" onclick="closeLayerOpen()"><i class="fa fa-reply mr5"></i>返回</button>
                   </div>
               </li>
            </ul>
    	</form>
    </div>
    <!-- </div> -->
</body>
<script type="text/javascript">
function closeLayerOpen(){
	parent.layer.close(parent.layer.getFrameIndex(window.name));
}

$("#editForm").validate({
	onkeyup : false,
	onsubmit: false,
	onfocusout: function(element){
	      $(element).valid() ;
				 },
	rules : {
		showOrder : {
			required : true,
			isDigits: true ,
			range : [1,10000]
		}
	},
	messages : {
		showOrder : {
		required : "请完善必填信息",
		isDigits: "请输入正确的排序号", 
		range : "请输入正确的排序号"
		}
	},
	errorPlacement: function(error, element) {
		 if(error){    //error存在的时候
			 $(element).next().html(error); //showMsg为你自定义的信息显示区域的id。
			
		 }                            //这里的element是录入数据的对象  
		 $(element).addClass('input-danger');
		 
	 },
	 success:function(label){
		 $(label).parent().prev().removeClass('input-danger');
		 $(label).remove();
	 }
});

function save(){
	if(!$("#s_showOrder").valid()){
		return false;
	}
	var id=$("#s_id").val();
	var showOrder=$("#s_showOrder").val();
	
	var data={
			id:id,
			showOrder:$.trim(showOrder)
			};
	//防止多次点击
	$("#savebtn").attr('disabled','disabled');
	
	
 	$.post("${ctx}/myapp/update/order",data,function(result){
		if(result.code=="success"){
			 layer.msg('操作成功', {
  	            icon: 1
  	        });
			 if(id == null || id == ''){
				 window.parent.jumpPage(1,'',true);
			 }else{
				 window.parent.jumpPage('','',true);
			 }
			 
			 setInterval("parent.layer.close(parent.layer.getFrameIndex(window.name))",2000);
			 
		}else{
			layer.msg('操作失败', {
  	            icon: 2
  	        });
			$("#savebtn").removeAttr('disabled');
		}
		
		
		
	},"json"); 
}

</script>
</html>